<template>
  <span class="go-back" @click="onBack">
    <img src="/@/assets/images/goback.png" alt="" />
    返回 <em v-if="label">|</em> <span v-if="label">{{ label }}</span>
  </span>
</template>

<script setup>
  import { ref } from 'vue';
  import { useRoute, useRouter } from 'vue-router';
  import { string } from 'vue3-json-viewer/dist/bundle.cjs';
  const router = useRouter();
  const route = useRoute();
  const props = defineProps({
    label: {
      type: String,
      default: '',
    },
    cb: {
      type: Function,
      default: null,
    },
  });

  function onBack() {
    if (props.cb) {
      props.cb();
      return;
    }
    router.back();
  }
</script>
<style scoped lang="less">
  .go-back {
    font-family: Microsoft YaHei;
    font-size: 22rem;
    color: #1169e5;
    margin-right: 200rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    z-index: 99;
    span {
      color: #b2b2b2;
    }
    em {
      margin: 0 8rem;
      font-style: normal;
      color: #b2b2b2;
    }
    img {
      width: 20rem;
      height: 19rem;
      margin-right: 14rem;
    }
  }
</style>
